Displaying deletion history in DXL layout column

In DOORS 8.2, I need to display who deleted some objects and when. My starting point is the following code (which works):
 

History h
HistoryType ht
for h in obj do
    {
        ht = h.type
        hd = h.date
        ha = h.author
        if (ht == deleteObject)
                {
                display(hd "\n" ha)
                }
        }

 


However, if I display the date and the author in the opposite order:

 

 

 

History h
HistoryType ht
for h in obj do
    {
        ht = h.type
        hd = h.date
        ha = h.author
        if (ht == deleteObject)
                {
                display(ha "\n" hd)
                }
        }



I get an error "incorrectly concatenated tokens". What gives?

THX,
Ken.



 

 


mcnairk - Fri Jul 13 15:34:41 EDT 2012

Re: Displaying deletion history in DXL layout column
SystemAdmin - Sat Jul 14 02:13:17 EDT 2012

There will be others who can explain this better in "SW speak" than I can, but the problem is related to your variable "hd" being of type date. The DXL "display" function is defined as a string type function. However, there is a subtle way that non string type data like variable "hd" can be converted to a string within string defined functions like "display".

In your first script, "hd" is followed by a string, namely "\n". This has the effect of forcing the preceding variable to be converted to type string if it is not a string itself, it's as if you had used the function stringOf(hd) to convert "hd" to a string.

In your second script, "ha" is already a string, but "hd" does not have a string immediately after it and is interpreted as type date which results in the DXL string concatenation error.

The solution - just add two empty quotes at the end of "hd" as shown below.
 

History h
HistoryType ht
for h in obj do
    {
        ht = h.type
        hd = h.date
        ha = h.author
        if (ht == deleteObject)
                {
                display(ha "\n" hd"")
                }
        }

Paul Miller
Melbourne, Australia

Re: Displaying deletion history in DXL layout column
llandale - Sat Jul 14 20:30:27 EDT 2012

Yes, its hard to tell in advance how "hd" will be auto-declared. This is a good example supporting developing programs with Autodeclare OFF.

-Louie

Re: Displaying deletion history in DXL layout column
llandale - Sat Jul 14 20:33:39 EDT 2012

llandale - Sat Jul 14 20:30:27 EDT 2012
Yes, its hard to tell in advance how "hd" will be auto-declared. This is a good example supporting developing programs with Autodeclare OFF.

-Louie

Forgot. Concatenation only works when the last thing in the list is a string.

Re: Displaying deletion history in DXL layout column
mcnairk - Mon Jul 16 08:37:28 EDT 2012

SystemAdmin - Sat Jul 14 02:13:17 EDT 2012

There will be others who can explain this better in "SW speak" than I can, but the problem is related to your variable "hd" being of type date. The DXL "display" function is defined as a string type function. However, there is a subtle way that non string type data like variable "hd" can be converted to a string within string defined functions like "display".

In your first script, "hd" is followed by a string, namely "\n". This has the effect of forcing the preceding variable to be converted to type string if it is not a string itself, it's as if you had used the function stringOf(hd) to convert "hd" to a string.

In your second script, "ha" is already a string, but "hd" does not have a string immediately after it and is interpreted as type date which results in the DXL string concatenation error.

The solution - just add two empty quotes at the end of "hd" as shown below.
 

History h
HistoryType ht
for h in obj do
    {
        ht = h.type
        hd = h.date
        ha = h.author
        if (ht == deleteObject)
                {
                display(ha "\n" hd"")
                }
        }

Paul Miller
Melbourne, Australia

Thanks mate!